#
# Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
#
#   GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
#   Author :  Shawn.Tan
#   Date : 2025.10.28
#
#   History : Initial Version 2025.10.28
#
#
from abc import ABC
from abc import abstractmethod

from base.exception_handlers.SecurityStateHandlerSet import (
    SecurityStateHandlerSet,
)


#  This class provides an interface for creating various objects necessary
#  for the generation of exception handlers.
class ExceptionsFactory(ABC):

    # Create a set of exception handlers for a given thread.
    #
    #  @param aGenThread A reference to the GenThread object.
    #  @param aMemBankHandlerRegistryRepo A reference to the memory bank
    #       handler registry repository.
    #  @param aStack The exception handler stack.
    @abstractmethod
    def createThreadHandlerSet(self, aGenThread, aMemBankHandlerRegistryRepo, aStack):
        raise NotImplementedError

    # Create a set of exception handlers for a given privilege level.
    #
    #  @param aGenThread A reference to the GenThread object.
    #  @param aPrivLevel The excecution privilege level.
    #  @param aMemBankHandlerRegistryRepo A reference to the memory bank
    #       handler registry repository.
    #  @param aStack The exception handler stack.
    @abstractmethod
    def createPrivilegeLevelHandlerSet(
        self, aGenThread, aPrivLevel, aMemBankHandlerRegistryRepo, aStack
    ):
        raise NotImplementedError

    # Create a set of exception handlers for a given security state.
    #
    #  @param aSecurityState The excecution security state.
    #  @param aMemBankHandlerRegistryRepo A reference to the memory bank
    #       handler registry repository.
    #  @param aStack The exception handler stack.
    def createSecurityStateHandlerSet(self, aSecurityState, aMemBankHandlerRegistryRepo, aStack):
        return SecurityStateHandlerSet(aSecurityState, aMemBankHandlerRegistryRepo, self, aStack)

    # Create an exception handler stack.
    #
    #  @param aGenThread A reference to the GenThread object.
    @abstractmethod
    def createExceptionHandlerStack(self, aGenThread):
        raise NotImplementedError

    # Create a default synchronous exception dispatcher.
    #
    #  @param aGenThread A reference to the GenThread object.
    @abstractmethod
    def createDefaultSynchronousExceptionDispatcher(self, aGenThread):
        raise NotImplementedError

    # Create a default fast synchronous exception dispatcher.
    #
    #  @param aGenThread A reference to the GenThread object.
    @abstractmethod
    def createDefaultFastSynchronousExceptionDispatcher(self, aGenThread):
        raise NotImplementedError

    # Create an assembly helper object.
    #
    #  @param aSequence A reference to the sequence being generated.
    @abstractmethod
    def createAssemblyHelper(self, aSequence):
        raise NotImplementedError
